(define threadnumber ;contador/closure para identificar as threads
  (let ((init -1)) ;vai incrementar, logo, começa do 0
    (lambda ()
      (set! init (+ 1 init))
      init)))

;; global vars
(define log '())
(define global-log '()) ;globallog: ((mutexname mutexlog) (mutexname 
(define program-start (current-time)) ;mutexlog: ((threadname op time) ... (threadname op time))

(define log!
  (lambda (obj threadname op)
    (let ((old-log (get-log obj)))
      (set-log! obj (cons
		     (list threadname op (current-time))
		     old-log)))))

					;globallog: ((mutexname mutexlog) (mutexname mutexlog) ...)
					;FIXME: estrutura temporária é globallog: ((mutexname newmutex) ... (mutexname newmutex)) - tirar mutex daqui
 (define add-to-global-log!
  (lambda (newmutex)
    (set! global-log (cons (list

			    (mutex-specific (get-mutex newmutex))
			    newmutex)
			   global-log))))